﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WinnerCMS.Common;

namespace WinnerCMS.CacheStorager
{
    public interface ICacheStorager
    {
        /// <summary>
        /// 添加指定ID的对象
        /// </summary>
        /// <param name="key"></param>
        /// <param name="t"></param>
        void Add<T>(string key, T t);

        /// <summary>
        /// 添加指定ID的对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="datetime"></param>
        void Add<T>(string key, T value, int datetime);

        /// <summary>
        /// 添加指定ID的对象
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <param name="datetimetype"></param>
        /// <param name="datetime"></param>
        void Add<T>(string key, T value, DateTimeType datetimetype, int datetime);

        /// <summary>
        /// 返回指定ID的对象
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        string Get(string key);

        /// <summary>
        /// 返回指定ID的对象
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        T Get<T>(string key);

        /// <summary>
        /// 试图获取缓存
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="key"></param>
        /// <param name="value"></param>
        /// <returns></returns>
        bool TryGet<T>(string key, out T value) where T : class;

        /// <summary>
        /// 移除指定ID的对象
        /// </summary>
        /// <param name="key"></param>
        void Remove(string key);

        void RemoveLike(string key);

        /// <summary>
        /// 到期时间
        /// </summary>
        int TimeOut { set; get; }

        /// <summary>
        /// 统计信息
        /// </summary>
        /// <returns></returns>
        Hashtable Stats();

        void Shutdown();

        /// <summary>
        /// 清空所有缓存
        /// </summary>
        void FlushAll();
    }
}